package com.test.aop.controller;

import com.test.aop.aspect.MyAspect;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@Slf4j
@RequestMapping("/user")
@RestController
public class UserController {

    @RequestMapping("/u1")
    public String u1(){
        log.info("执行u1");
//        int sum = 1;
//        for (int i = 0; i < 10; i++) {
//            sum += sum;
//        }
//        log.info("sum的值为："+sum);
        try{
            int i = 10/0;
        }catch (ArithmeticException e){
            log.error("出现异常:",e);
        }

        return "u1";
    }

    @MyAspect
    @RequestMapping("/u2")
    public String u2(){
        log.info("执行u2");
        return "u2";
    }
}
